import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:namewava/utils/jc_image_path.dart';
import 'package:namewava/utils/jc_screenutil_info.dart';
import 'package:namewava/utils/jc_text_style.dart';

class JcNav extends StatelessWidget {
  const JcNav(
      {super.key,
      this.title,
      this.backFunction,
      this.rightImage,
      this.rightBtnEvent});
  final String? title;
  final String? rightImage;

  final Function? backFunction;
  final Function? rightBtnEvent;
  @override
  Widget build(BuildContext context) {
    return Container(
      //padding: EdgeInsets.symmetric(horizontal: 24.w),
      padding: EdgeInsets.only(
          left: 30.w, right: 30.w, top: JcScreenutilInfo.statusBarHeight),
      // color: Colors.red,
      height: JcScreenutilInfo.statusBarHeight + 64,
      // color: Colors.yellow,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          GestureDetector(
            child: Image.asset(
              JcImagePath.jcBackIcon,
              width: 36.w,
              height: 36.w,
              fit: BoxFit.fill,
            ),
            onTap: () {
              _backEvents();
            },
          ),
          Text(
            title ?? '',
            style: JcTextStyle.poetsenOneRegularTextStyle(24.sp, Colors.white),
          ),
          rightImage != null
              ? GestureDetector(
                  child: Image.asset(
                    rightImage!,
                    width: 36.w,
                    height: 36.w,
                  ),
                  onTap: () {
                    _rightEvents();
                  },
                )
              : SizedBox(
                  width: 36.w,
                )
        ],
      ),
    );
  }

  _backEvents() {
    if (backFunction != null) {
      backFunction!();
    }
  }

  _rightEvents() {
    if (rightBtnEvent != null) {
      rightBtnEvent!();
    }
  }
}
